home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_kdelibs.idb / usr / freeware / kde / include / mediatool.h.z / mediatool.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  10.0 KB  |  319 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1997 Christian Esken (esken@kde.org)
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.     Boston, MA 02111-1307, USA.
  18. */
  19. #ifndef MEDIATOOL_H
  20. #define MEDIATOOL_H
  21.  
  22. typedef signed char    int8;
  23. typedef unsigned char  uint8;
  24. typedef signed int     int32;
  25. typedef unsigned int   uint32;
  26. typedef unsigned short uint16;
  27.  
  28. #define LEN_NAME     32
  29. #define LEN_FNAME    256
  30. #define MAX_PATTERNS    10
  31.  
  32.  
  33. /*****************************************************************************
  34.  * Now comes everything about the connections.
  35.  * Creating, connecting and disconnecting.
  36.  *****************************************************************************/
  37. typedef struct
  38. {
  39.   int        ref;
  40.   int        talkid;
  41.   char        *shm_adr;
  42. } MediaCon;
  43.  
  44.  
  45. void MdConnect(int shm_talkid, MediaCon *mcon);
  46. void MdConnectNew(MediaCon *mcon);
  47. void MdDisconnect(MediaCon *mcon);
  48. void MdConnectInit(void);
  49.  
  50.  
  51. /*****************************************************************************
  52.  * Now comes everything about the playlists.
  53.  * Creating, adding a item and so on.
  54.  *****************************************************************************/
  55. typedef struct MdPlayItem
  56. {
  57.   char            *Item;
  58.   struct MdPlayItem    *Prev; /* Should be of type MdPlayItem !! */
  59.   struct MdPlayItem    *Next;
  60. } MdPlayItem_t;
  61.  
  62. typedef struct
  63. {
  64.   int32                count;
  65.   struct MdPlayItem        *Current;
  66.   struct MdPlayItem        *First;
  67.   struct MdPlayItem        *Last;
  68. } MdPlaylist;
  69.  
  70. MdPlaylist* PlaylistNew(void);
  71. struct MdPlayItem* PlaylistAdd( MdPlaylist* Playlist, const char *fileURL, int32 pos );
  72. void PlaylistShow( MdPlaylist* Playlist );
  73.  
  74.  
  75.  
  76.  
  77. /*****************************************************************************
  78.  * Event counter definition:
  79.  * A single event counter counts a single dedicated event. Events used in
  80.  * the mediatool protocol are usually key presses. The masters increments
  81.  * the "current" item each time an event occurs. Functions are available
  82.  * for the slave to check how many key presses occured since his last
  83.  * "sampling".
  84.  *****************************************************************************/
  85. typedef struct
  86. {
  87.   uint32           current;    /* Must be unsigned (!!!) */
  88.   uint32           last;
  89. } EventCounter;
  90.  
  91.  
  92. void   EventCounterRaise(EventCounter *evc, uint32 count);
  93. uint32 EventCounterRead(EventCounter *evc, uint32 max);
  94. void   EventCounterReset(EventCounter *evc);
  95.  
  96.  
  97.  
  98. /***********************************************************************************
  99.  * Now comes everything about the chunks.
  100.  ***********************************************************************************/
  101.  
  102. /* Definition of the chunk structure */
  103. typedef struct
  104. {
  105.     int32    DataLength;    /* Length of data field [maximum: (2^31)-1 ]     */
  106.     char    Type[4];    /* Chunk type. Ascii readable                    */
  107. /*  char    Data[];   */    /* Chunk data. The contents is dependend on     */
  108.                 /* the chunk type. It is described below.    */
  109. } MdChunk;
  110.  
  111.  
  112.  
  113.  
  114. /***********************************************************************************
  115.  * Definition of the various chunks (Data portions!).
  116.  * Only the data portion of the chunk is included in the structures.
  117.  ***********************************************************************************/
  118.  
  119.  
  120.  
  121. /* CHUNK: Header */
  122. /* The version number of the protocol is built by the two values
  123.    revision and version: The protocol is of version revision.version.
  124.    For example, if revision is 1 and version is 13, it is version 13
  125.    if revision 1. Masters and slaves should use the same revision.
  126.    The version may differ, as versions with the same revisions are
  127.    compatible. They will only contain bug fixes or minor changes
  128.    as new chunk types
  129.  */
  130.    
  131. typedef struct
  132. {
  133.   int32        shm_size;    /* Size of shared memory segment.    */
  134.   int32        ref;        /* Reference id.            */
  135.   /* Connection name, e.g: "tracker" or "playmidi". Set by the master.  */
  136.   char        name[LEN_NAME+1];
  137.   int8        revision;    /* Protocol revision            */
  138.   int8        version;    /* Protocol version            */
  139.   char          ipcfname[40];   /* Remember IPC filename for unlink()   */
  140. } MdCh_IHDR;
  141.  
  142.  
  143.  
  144. /* CHUNK: Play options */
  145. /* !!! Not yet supported. Structure may change soon. */
  146. typedef struct
  147. {
  148.   int32        repeats;    /* 0:forever, 1: 1 time, 2: 2 times, ..    */
  149.   int32        transpose;    /* Tanspose all notes by "tanspose"     *
  150.                    * half notes up (poitive value) or    *
  151.                  * down (negative values)        */
  152.   int8        NTSCtiming;    /* 0:PALtiming(50Hz), 1:NTSCtiming(60Hz)*/
  153.   int8        samplesize;    /* 8 or 16 for today            */
  154.   int8        stereo;        /* 0: Mono, 100: Full stereo        *
  155.                    * Values in between are allowed.    */
  156.   int8        oversample;    /* Oversampling factor            */
  157. } MdCh_POPT;
  158.  
  159.  
  160.  
  161. /* CHUNK: Player information. */
  162. typedef struct
  163. {
  164.   float        version;
  165.   char        name[LEN_NAME+1];    /* Player name. Looks like    */
  166.                     /* "tracker V4.32"        */
  167. } MdCh_PINF;
  168.  
  169.  
  170.  
  171. /* CHUNK: Key status ("Master status") */
  172. typedef struct
  173. {
  174.   /* The now following EventCounters are higher level representations
  175.    * of key presses. They tell, how often a key was pressed since last
  176.    * reading the event counter.
  177.    */
  178.   EventCounter    forward;           /* Event counter: Forward        */
  179.   EventCounter    backward;          /* Event counter: Backward        */
  180.   EventCounter    prevtrack;         /* Event counter: Previous track           */
  181.   EventCounter    nexttrack;         /* Event counter: Next Track        */
  182.   EventCounter    exit;        /* Event counter: Exit player          */
  183.   EventCounter    eject;        /* Event counter: Eject media/playlist    */
  184.   EventCounter    play;        /* Event counter: Play            */
  185.   EventCounter    stop;        /* Event counter: Stop            */
  186.   /* The pause key is an add-on. It is not helpful to use an event
  187.    * counter with the pause key. The key is simply pressed or unpressed.
  188.    */
  189.   int8        pause;        /* Status: Pause key            */
  190.   uint8        sync_id;    /* This is for helping with KAudio->snyc() */
  191.   EventCounter    posnew;        /* Event counter: Notification of pos_new change */
  192.   uint32    pos_new;    /* Wished play position */
  193.   uint32        pos_new_m;      /* Wished play position 1/1000 (milli) */
  194. } MdCh_KEYS;
  195.  
  196.  
  197.  
  198. /* CHUNK: Player status ("Slave status") */
  199. typedef struct
  200. {
  201.   uint32    status;        /* Status of client. (Bit array).          */
  202.   int32        supp_keys;    /* Which keys are supported by the    */
  203.                        /* player (Bit array).            */
  204.   uint32    pos_current;    /* Curr. play position (eg: event num)     */
  205.   uint32    pos_max;    /* Max. play position (eg: num events)    */
  206.   char        songname[LEN_NAME+1];
  207.   uint8        sync_id;    /* This is for helping with KAudio->snyc() */
  208.   uint32        pos_current_m;  /* Curr. play position (milli)        */
  209. } MdCh_STAT;
  210.  
  211.  
  212.  
  213. /* CHUNK: Filename */
  214. typedef struct
  215. {
  216.   EventCounter    count;    /* Synchronizing primitive for chunk    */
  217.   char        filename[LEN_FNAME+1];
  218. } MdCh_FNAM;
  219.  
  220.  
  221. /* CHUNK: Text message */
  222. typedef struct
  223. {
  224.   int32        category;          /* What category falls the text in?    */
  225.                        /* e.g: lyric, errormessage, other         */
  226.   int32        info1;        /*                    */
  227.   int32        info2;        /*                    */
  228.   /* char          text[SIZE]; */    /* Text message                */
  229. } MdCh_TEXT;
  230.  
  231.  
  232. /*
  233.  * The end chunk has no data portion. So there┤s no point in defining an
  234.  * corresponding (empty) END-Chunk. The only effect would be an C compiler
  235.  * complaining about "empty" structure definitions and the like.
  236.  *
  237.  * typedef struct
  238.  * {
  239.  *
  240.  * } MdCh_IEND;
  241.  */
  242.  
  243.  
  244. /* The chunk commands */
  245. MdChunk* FindChunk(char *adress, char *ChunkName);
  246. void*    FindChunkData(char *adress, char *ChunkName);
  247. MdChunk* WriteChunk (char *adress, char *ChunkName, char *data, int32 length);
  248.  
  249.  
  250. /***********************************************************************************
  251.  * Now comes the filename handling.
  252.  ***********************************************************************************/
  253.  
  254.  
  255. void FileNameSet(MdCh_FNAM *fnChunk, char *filename);
  256. int8 FileNameGet(MdCh_FNAM *fnChunk, char *filename);
  257.  
  258.  
  259. int MediatypesInit(void);
  260.  
  261. typedef struct
  262. {
  263.   char *Name;
  264.   char *Description;
  265.   char *Patterns[MAX_PATTERNS];
  266.   int8 num_patterns;
  267.   int8 argc;
  268.   char *argv[MAX_PATTERNS];
  269. } MediaType;
  270.  
  271.  
  272. #define MD_KEY_PREVTRACK      1
  273. #define MD_KEY_NEXTTRACK      2
  274. #define MD_KEY_FORWARD          4
  275. #define MD_KEY_BACKWARD          8
  276. #define MD_KEY_PAUSE         16
  277. #define MD_KEY_PLAY         32
  278. #define MD_KEY_EXIT         64
  279. #define MD_KEY_EJECT        128
  280. #define MD_KEY_STOP        256
  281.  
  282. #define MD_STAT_INIT          1
  283. #define MD_STAT_READY          2
  284. #define MD_STAT_EXITED           4
  285. #define MD_STAT_BUSY          8
  286. #define MD_STAT_PLAYING         16
  287. #define MD_STAT_PAUSING         32
  288.  
  289. /*
  290.  * Special note about "MD_CAT_NAME". This is not to be confused with the file
  291.  * name. Several media formats have a name stored internally. For example, a
  292.  * soundtracker module always has an internal name. Within midi songs, some
  293.  * people use the first "Sequence/Track" field as the song name, but this is
  294.  * no standard (So a midi player cannot tell the "real" name of a song).
  295.  */
  296.  
  297. #define MD_CAT_OTHER         1 /* Any message, not fitting in any   */
  298.                    /* other category            */
  299. #define MD_CAT_LYRIC         2 /* Lyrics (Text of song)        */
  300. #define MD_CAT_ERROR         3 /* Error channel. Use instead of    */
  301.                    /* writing to stderr.               */
  302. #define MD_CAT_COPYRIGHT     4 /* Copyright notice            */
  303. #define MD_CAT_NAME         5 /* Name of media            */
  304. #define MD_CAT_INSTRUMENT     6 /* Instrument name, use "info1"    */
  305.                    /* field for intrument number           */
  306. #define MD_CAT_AUTHOR         7 /* Name of original author        */
  307.                           /* (e.g.: Johann Sebastian Bach)    */
  308. #define MD_CAT_TRANSCRIBER     8 /* Name of transciber        */
  309.                    /* (e.g.: Rob Hubbard)        */
  310. #define MD_CAT_FILETYPE         9 /* e.g. "General Midi", "MT32" or    */
  311.                    /* "PSID single-file"        */
  312.  
  313. #endif /* MEDIATOOL_H */
  314.  
  315.  
  316.  
  317.  
  318.  
  319.